﻿namespace Digitalmes.Application.Sys.Orgs.Queries;

/// <summary>
/// 机构树结构查询命令。
/// </summary>
public record GetOrgQuery : IRequest<IResult<List<SysOrgDto>>>;

internal sealed class GetOrgQueryHandler(IRepository<SysOrg> repo) : IRequestHandler<GetOrgQuery, IResult<List<SysOrgDto>>>
{
    public async Task<IResult<List<SysOrgDto>>> Handle(GetOrgQuery request, CancellationToken cancellationToken)
    {
        var orgs = await repo.GetListAsync(cancellationToken);
        return Result.From(orgs.Adapt<List<SysOrgDto>>());
    }
}
